﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using FinosLibrary;
namespace FinosServiceLibrary.Server {
    public class AdminClient:Client {
        public static Dictionary<string, AdminClient> admins = new Dictionary<string,AdminClient>();
        public bool receiveServerLog;
        public AdminClient()
            : base() {
            admins[id] = this;
        }
        public static void TraceMessage(string app,string[] _msg) {
            string msg = string.Join(",", _msg);
            msg = "[" + DateTime.Now.ToLocalTime() + "]:" + msg;
            broadcast("TraceMessage", new string[] { app, msg });
        }
        public static void TraceMessage(string msg) {
            foreach (AdminClient client in admins.Values) {
                if (client.receiveServerLog) {
                    client.call("ServerLog", msg);
                }
            }
        }
        public static void broadcast(string fun,object arg) {
            foreach (AdminClient client in admins.Values) {
                client.call(fun,arg);
            }
        }
    }
}
